package pruebaFactory;

public class VehiculoFactory implements IVehiculoFactory {

	private static IVehiculoFactory instance;
	
	public static synchronized IVehiculoFactory getInstance() {
		if(instance == null){
			instance = new VehiculoFactory();
		}
		return instance;
	}
	
	private VehiculoFactory() {
		super();
	}

	@Override
	public IVehiculo crearVehiculo(String nombre) {
		if("auto".equals(nombre)) {
			return new IVehiculo.Auto();
		}else if("moto".equals(nombre)) {
			return new IVehiculo.Moto();
		} else if("camion".equals(nombre)) {
			return new IVehiculo.Camion();
		}
		throw new RuntimeException(nombre + " is an unsupported Vehiculo.");
	}
	
	
}